<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	
	<link href="images/reset.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<link href="images/system.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<link href="images/table_form.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
	<link href="images/workspace.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" /> 
	<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" />
	
	<script src="../js/jquery-1.8.0.min.js?v={yun:}$config.cachecode{/yun}"></script>
	<script src="js/admin_public.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script> 
	<script src="js/crm.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script> 
	<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
	<script src="{yun:}$config.sy_weburl{/yun}/js/layui/phpyun_layer.js?v={yun:}$config.cachecode{/yun}"></script>
	
	<title>后台管理</title>
	
</head>

<body class="body_ifm">
	<div class="infoboxp">
	
		<div class="tabs_info" style="height:36px;">
        	<ul>
               	<li class="curr"><a href="index.php?m=crm_waitingtask">我的任务</a></li>
               	{yun:}if in_array('804',$power){/yun}
               	<li><a href="index.php?m=crm_waitingtask&c=depart">下属的任务</a></li>
               	{yun:}/if{/yun}
           	</ul>
		</div>

		<div class="crm_searctime">
        	<ul>
               	<li {yun:}if !$smarty.get.time{/yun}class="curr"{yun:}/if{/yun}><a href="index.php?m=crm_waitingtask">今天</a></li>
               	<li {yun:}if $smarty.get.time==1{/yun}class="curr"{yun:}/if{/yun}><a href="index.php?m=crm_waitingtask&time=1">明天</a></li>
               	<li {yun:}if $smarty.get.time==2{/yun}class="curr"{yun:}/if{/yun}><a href="index.php?m=crm_waitingtask&time=2">后天</a></li>
               	<li {yun:}if $smarty.get.time==3{/yun}class="curr"{yun:}/if{/yun}><a href="index.php?m=crm_waitingtask&time=3">一周内</a></li>
               	<li {yun:}if $smarty.get.time==4{/yun}class="curr"{yun:}/if{/yun}><a href="index.php?m=crm_waitingtask&time=4">所有任务</a></li>
           	</ul>
		</div>
		
		<iframe id="supportiframe"  name="supportiframe" onload="returnmessage('supportiframe');" style="display:none"></iframe>
		<form class="layui-form" action="index.php" name="myform" method="get" id='myform' target="supportiframe">
			
			<input type="hidden" name="pytoken"  id='pytoken' value="{yun:}$pytoken{/yun}">
			<input name="m" value="crm_waitingtask" type="hidden"/>
			
			<div class="crm_newly_build_tit" style="padding:0; padding-top:10px;">
		 		<div class="layui-input-inline">
					<select name="status" id="status" lay-filter='status'>
						<option value="1" {yun:}if $smarty.get.status ==1 || !$smarty.get.status{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c type=$smarty.get.type adv='1' adt='status' untype='status'{/yun}">进行中</option>
						<option value="2" {yun:}if $smarty.get.status ==2{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c type=$smarty.get.type adv='2' adt='status' untype='status'{/yun}">已完成</option>
						<option value="3" {yun:}if $smarty.get.status ==3{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c type=$smarty.get.type adv='3' adt='status' untype='status'{/yun}">未完成</option>
						<option value="4" {yun:}if $smarty.get.status ==4{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c type=$smarty.get.type adv='4' adt='status' untype='status'{/yun}">已取消</option>
						<option value="5" {yun:}if $smarty.get.status==5{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c  type=$smarty.get.type adv='5' adt='status' untype='status'{/yun}">全部</option>
					</select>
				</div>
				
				<div class="layui-input-inline">
					<select name="type" id="type" lay-filter='type'>
						<option value='' data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c status=$smarty.get.status adv=$v adt='type' untype='type'{/yun}">任务类型</option>
						{yun:}foreach from = $cache.crmdata.task_type item=v{/yun}
							<option value="{yun:}$v{/yun}" {yun:}if $smarty.get.type ==$v{/yun}selected{yun:}/if{/yun} data-url="{yun:}searchurl m=$smarty.get.m c=$smarty.get.c status=$smarty.get.status adv=$v adt='type' untype='type'{/yun}">{yun:}$cache.crmclass_name[$v]{/yun}</option>
                     	{yun:}/foreach{/yun}
					</select>
				</div>
			</div>
			
			<div class="table-list" style="color:#898989; margin-top:10px;">
				<div class="admin_table_border">	
					<table width="100%">
						<thead>
							<tr class="admin_table_top">
	                          	<th align="left" ><div class="crm_listpd">客户名称</div></th>
	                           	<th align="left">任务类型</th>
	                           	<th align="left">任务事项</th>
								<th align="left">提交人</th>
	                           	<th>提交时间</th>
								<th>任务时间</th>
								<th>完成时间</th>
								<th>任务反馈</th>
	 							<th>操作</th>
							</tr>
						</thead>
						
						<tbody>
						{yun:}foreach item=v key=key from=$tasks{/yun}
						
							<tr align="center" {yun:}if ($key+1)%2=='0'{/yun}class="admin_com_td_bg"{yun:}/if{/yun} id="list{yun:}$v.id{/yun}">
                               	<td align="left">
	                               	<div class="crm_listpd">
	                               		{yun:}$v.name{/yun}
	                               	<div class="">	<a href="javascript:OpenContact('{yun:}$v.comid{/yun}','index.php?m=crm_waitingtask&c=ComDetail')" title="联系方式" class="crm_comtel">联系方式</a></div>
	                               	</div>
                             	</td>
                             	<td align="left">{yun:}$cache.crmclass_name[$v.type]{/yun}</td>
                             	<td align="left"><div class="crm_rwsx">{yun:}$v.content{/yun}</div></td>
								<td align="left">{yun:}$v.aname{/yun}</td>
                             	<td>
                             		{yun:}$v.ctime_n{/yun}
                             		<div class="crm_time_b"><font color="red">{yun:}$v.addDay{/yun}</font></div>
                             	</td>
                               	<td>
                               		<div class="crm_rwtime">
                               		{yun:}if $v.stime{/yun}
                               			{yun:}$v.stime_n{/yun}
                               			<div class="crm_time_b"><font color="red">{yun:}$v.taskDay{/yun}</font></div>
                               			{yun:}if $v.stime lt time() && $v.status != '2'{/yun} <span class="crm_rwtime_gq">已过期</span>{yun:}/if{/yun}
                               		{yun:}else{/yun}
                               			--	
                               		{yun:}/if{/yun}
                               		</div>
                               	</td>
                               	<td>
                               		{yun:}if $v.status == '1'{/yun} 
                               			<span style="color:#FF0000;">进行中</span>
									{yun:}else if $v.status == '2'{/yun} 
										<span style="color:green"> {yun:}$v.etime|date_format:"%Y-%m-%d"{/yun} </span>
									{yun:}else if $v.status == '3'{/yun}
										<span style="color:#FF0000;"> 未完成 </span>
									{yun:}else if $v.status == '4'{/yun} 
										<span style="color:#f60">已取消</span>
									{yun:}/if{/yun}
								</td>
								
								
								<td align="left">
									<div class="crm_rwsx" style="font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
										{yun:}if $v.reason{/yun}{yun:}$v.reason{/yun}{yun:}else{/yun}<div style="width:100%; text-align:center">--</div>{yun:}/if{/yun}
									</div>
								</td>
								
								<td align="center" width="240">
									{yun:}if $v.status == '1'{/yun}
										{yun:}if $v.type == 22{/yun} 
											<a href="javascript:void(0)" class="crm_submit CrmnewFollow" data-uid="{yun:}$v.comid{/yun}" data-name="{yun:}$v.name{/yun}" data-type="{yun:}$v.type{/yun}" data-taskid="{yun:}$v.id{/yun}" >完成</a>
										{yun:}else{/yun} 
											<a href="javascript:void(0)" onclick="settaskstatus('2','{yun:}$v.id{/yun}','index.php?m=crm_waitingtask&c=setStatus')"  class="crm_submitwc">完成</a>
                                            
										{yun:}/if{/yun}
										<a href="javascript:void(0)" onclick="settaskstatus('3','{yun:}$v.id{/yun}','index.php?m=crm_waitingtask&c=setStatus')"  class="crm_submitwwc">未完成</a>
										<a href="javascript:void(0)" onclick="settaskstatus('4','{yun:}$v.id{/yun}','index.php?m=crm_waitingtask&c=setStatus')"  class="crm_submitqx">取消任务</a>
									{yun:}/if{/yun}
									{yun:}if $v.status == '2'{/yun}
										<span style="color:green"> [已完成] </span>
									{yun:}/if{/yun}
									{yun:}if $v.status == '3'{/yun}
										<span style="color:#FF0000"> [未完成] </span>
									{yun:}/if{/yun}
								</td>
							</tr>
						{yun:}foreachelse{/yun}
      					
	      					<tr align="center">
					        	<td class="ud" colspan="5"><div class="admin_notip">暂无任务安排，换个条件试试~</div></td>
					      	</tr>
      					
						{yun:}/foreach{/yun}
						
						{yun:}if $total > $config.sy_listnum {/yun}
							<tr>
								{yun:}if $pagenum==1{/yun}
									<td colspan="2"> 从 1 到 {yun:}$config.sy_listnum {/yun} ，总共 {yun:}$total{/yun} 条</td>
								{yun:}else if $pagenum > 1 && $pagenum < $pages{/yun}
									<td colspan="2"> 从 {yun:}($pagenum-1) * $config.sy_listnum + 1{/yun} 到 {yun:}$pagenum * $config.sy_listnum{/yun} ，总共 {yun:}$total{/yun} 条</td>
								{yun:}else if $pagenum == $pages{/yun}
									<td colspan="2"> 从 {yun:}($pagenum-1) * $config.sy_listnum + 1{/yun} 到 {yun:}$total{/yun} ，总共 {yun:}$total{/yun} 条</td>
								{yun:}/if{/yun}
								<td colspan="3" class="digg">{yun:}$pagenav{/yun}</td>
							</tr>
						{yun:}/if{/yun}
						</tbody>
					</table>
				</div>
			</div>
		</form>
	</div>
	
	<div id="taskstatus" style="display:none; width:auto">
		<table cellspacing='1' cellpadding='1' class="admin_examine_table">
			<tr>
				<td align="center" style="padding:20px;">
					<textarea id="reason" name="reason" class="admin_explain_textarea" style="width: 350px;height:150px;"></textarea>
				</td>
			</tr>
			<tr id="taskreasonsubmit">
				<td align="center">
					<input type="hidden" id="task_status" value="" />
					<input type="button" onclick="setStatusu();" value='保存' class="admin_examine_bth">
					<input type="button" class="admin_examine_bth_qx" onClick="layer.closeAll();" value='关闭'>
				</td>
			</tr>
		</table>
  	</div>
  	
	<div id="taskstatusqx" style="display:none; width: 430px;text-align:center; ">
		<form class='layui-form'>
			<table cellspacing='1' cellpadding='1' class="admin_examine_table">
				<tr>
					<td align="left">
						<div class="layui-form-item">
							<div class="layui-input-block">
								<div class="admin_examine_right" style="width: 330px;">
									<input name="type" value="1" title="取消任务 (将任务设为已取消状态)" checked type="radio" /> 
								</div>
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td align="left">
						<div class="layui-form-item">
							<div class="layui-input-block">
								<div class="admin_examine_right" style="width: 330px;">
									<input name="type" value="2" title="删除任务 (彻底删除且不可恢复)" type="radio" /> 
								</div>
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan='2' align="center">
						<input type="button" onclick="setStatusqx();" value='保存' class="admin_examine_bth">
						<input type="button" class="admin_examine_bth_qx" onClick="layer.closeAll();" value='关闭'>
					</td>
				</tr>
			</table>
		</form>	
   </div>
   
	<input type="hidden" name="taskid" id="taskid" value="">
	
	<script>
		var weburl="{yun:}$config.sy_weburl{/yun}";
		
		layui.use(['form', 'laydate'], function(){
			var form = layui.form
				,laydate = layui.laydate
				,$ = layui.$;
			
			form.on('select(status)', function(data){
				var url=$('#status option:selected').attr('data-url');
				location.href=url;
			});
			form.on('select(type)', function(data){
				var url=$('#type option:selected').attr('data-url');
				if(url){
					location.href=url;
				}else{
					location.href='index.php?m=crm_waitingtask';
				}
			});
			
			laydate.render({
				elem: '#stime'
				,type: 'datetime'
			});
		});
		
		function settaskstatus(status,id,url){
			
			var pytoken	= $('#pytoken').val();
			
			if(status==2 || status==3){
				$('#task_status').val(status);
				$('#taskid').val(id);
				$('#taskreasonsubmit').show();
			 	$.layer({
					type : 1,
					title :'任务反馈', 
					closeBtn : [0 , true],
					border : [10 , 0.3 , '#000', true],
					area : ['auto','300px'],
					offset: ['20px', ''],
					page : {dom :"#taskstatus"}
				}); 	
			}else if(status==4){
				$('#taskid').val(id);
				$.layer({
					type : 1,
					title :'取消任务', 
					closeBtn : [0 , true],
					border : [10 , 0.3 , '#000', true],
					area : ['300px','200px'],
					offset: ['20px', ''],
					page : {dom :"#taskstatusqx"}
				});
			}
		}
		
		function setStatusu(){
			var pytoken	= $('#pytoken').val();
			var status	= $('#task_status').val();
			var id 		= $('#taskid').val();
			var reason 	= $('#reason').val();
			if(!reason && status == 3){
				layer.msg('请填写任务反馈信息！',2,8);return false;
			}
			loadlayer();
			$.post(weburl+'/admin/index.php?m=crm_waitingtask&c=setStatus',{pytoken:pytoken,status:status,id:id,reason:reason,type:1},function(data){
				parent.layer.closeAll('loading');
				if(data==1){
					location.reload();
				}
			});
		}
		
		function setStatusqx(){
			var pytoken = 	$('#pytoken').val();
			var id 		= 	$('#taskid').val();
			var type	=	$('input[name="type"]:checked').val();
			loadlayer();
			$.post(weburl+'/admin/index.php?m=crm_waitingtask&c=setStatus',{pytoken:pytoken,status:4,id:id,type:type},function(data){
				parent.layer.closeAll('loading');
				if(data==1){
					location.reload();
				}
			});
		}
	</script>
	
 	{yun:}include file="$adminstyle/crm_public.htm"{/yun}
 	
</body>
</html>